home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus Leser 15 / Amiga Plus Leser CD 15.iso / Tools / Development / PowerD_mui / examples / Balancing.d < prev    next >
Encoding:
Text File  |  2002-03-13  |  3.8 KB  |  138 lines

  1. /*
  2. ** MUI-Demosource in D.
  3. **
  4. ** Based on the MUI-Demosource in E.
  5. ** Based on the C example 'Balancing.c' by Stefan Stuntz.
  6. ** Translated to E by Sven Steiniger
  7. ** Translated to D by Martin Kuchinka
  8. */
  9.  
  10. OPT    OPTIMIZE
  11.  
  12. MODULE    'muimaster',
  13.             'libraries/mui',
  14.             'intuition/classes',
  15.             'intuition/classusr',
  16.             'dos/dos',
  17.             'utility/tagitem',
  18.             'utility/hooks',
  19.             'lib/amiga'
  20.  
  21. DEF    MUIMasterBase
  22.  
  23. PROC main()
  24.     DEF    app=NIL,window,sigs=0
  25.  
  26.     IFN MUIMasterBase:=OpenLibrary(MUIMASTER_NAME,MUIMASTER_VMIN) THEN
  27.         Raise('Couldn''t open muimaster.library')
  28.  
  29.     app:=ApplicationObject,
  30.         MUIA_Application_Title,      'BalanceDemo',
  31.         MUIA_Application_Version,    '$VER: BalanceDemo 12.10 (21.11.95)',
  32.         MUIA_Application_Copyright,  '©1995, Stefan Stuntz',
  33.         MUIA_Application_Author,     'Stefan Stuntz',
  34.         MUIA_Application_Description,'Show balancing groups',
  35.         MUIA_Application_Base,       'BALANCEDEMO',
  36.  
  37.         SubWindow, window:=WindowObject,
  38.             MUIA_Window_Title, 'Balancing Groups',
  39.             MUIA_Window_ID,    "BALA",
  40.             MUIA_Window_Width ,MUIV_Window_Width_Screen(50),
  41.             MUIA_Window_Height,MUIV_Window_Height_Screen(50),
  42.  
  43.             WindowContents,HGroup,
  44.  
  45.                 Child,VGroup,GroupFrame,MUIA_Weight,15,
  46.                     Child,RectangleObject,TextFrame,MUIA_Weight,50,End,
  47.                     Child,RectangleObject,TextFrame,MUIA_Weight,100,End,
  48.                     Child,BalanceObject,End,
  49.                     Child,RectangleObject,TextFrame,MUIA_Weight,200,End,
  50.                 End,
  51.  
  52.                 Child,BalanceObject,End,
  53.  
  54.                 Child,VGroup,
  55.                     Child,HGroup,GroupFrame,
  56.                         Child,RectangleObject,TextFrame,MUIA_ObjectID,123,End,
  57.                         Child,BalanceObject,End,
  58.                         Child,RectangleObject,TextFrame,MUIA_ObjectID,456,End,
  59.                     End,
  60.                     Child,HGroup,GroupFrame,
  61.                         Child,RectangleObject,TextFrame,End,
  62.                         Child,BalanceObject,End,
  63.                         Child,RectangleObject,TextFrame,End,
  64.                         Child,BalanceObject,End,
  65.                         Child,RectangleObject,TextFrame,End,
  66.                         Child,BalanceObject,End,
  67.                         Child,RectangleObject,TextFrame,End,
  68.                         Child,BalanceObject,End,
  69.                         Child,RectangleObject,TextFrame,End,
  70.                     End,
  71.                     Child,HGroup,GroupFrame,
  72.                         Child,HGroup,
  73.                             Child,RectangleObject,TextFrame,End,
  74.                             Child,BalanceObject,End,
  75.                             Child,RectangleObject,TextFrame,End,
  76.                         End,
  77.                         Child,BalanceObject,End,
  78.                         Child,HGroup,
  79.                             Child,RectangleObject,TextFrame,End,
  80.                             Child,BalanceObject,End,
  81.                             Child,RectangleObject,TextFrame,End,
  82.                         End,
  83.                     End,
  84.                     Child,HGroup,GroupFrame,
  85.                         Child,RectangleObject,TextFrame,MUIA_Weight,50,End,
  86.                         Child,RectangleObject,TextFrame,MUIA_Weight,100,End,
  87.                         Child,BalanceObject,End,
  88.                         Child,RectangleObject,TextFrame,MUIA_Weight,200,End,
  89.                     End,
  90.                     Child,HGroup,GroupFrame,
  91.                         Child,SimpleButton('Also'),
  92.                         Child,BalanceObject,End,
  93.                         Child,SimpleButton('Try'),
  94.                         Child,BalanceObject,End,
  95.                         Child,SimpleButton('Sizing'),
  96.                         Child,BalanceObject,End,
  97.                         Child,SimpleButton('With'),
  98.                         Child,BalanceObject,End,
  99.                         Child,SimpleButton('Shift'),
  100.                     End,
  101.                 End,
  102.             End,
  103.         End,
  104.     End
  105.  
  106.     IFN app THEN Raise('Failed to create Application.')
  107.  
  108.     DoMethod(window,MUIM_Notify,MUIA_Window_CloseRequest,MUI_TRUE,
  109.         app,2,MUIM_Application_ReturnID,MUIV_Application_ReturnID_Quit)
  110.  
  111.  
  112. /*
  113. ** This is the ideal input loop for an object oriented MUI application.
  114. ** Everything is encapsulated in classes, no return ids need to be used,
  115. ** we just check if the program shall terminate.
  116. ** Note that MUIM_Application_NewInput expects sigs to contain the result
  117. ** from Wait() (or 0). This makes the input loop significantly faster.
  118. */
  119.  
  120.     set(window,MUIA_Window_Open,MUI_TRUE)
  121.  
  122.     WHILEN DoMethod(app,MUIM_Application_NewInput,&sigs)=MUIV_Application_ReturnID_Quit
  123.         IF sigs THEN sigs:=Wait(sigs)
  124.     ENDWHILE
  125.  
  126.     set(window,MUIA_Window_Open,FALSE)
  127.  
  128.  
  129. /*
  130. ** Shut down...
  131. */
  132.  
  133. EXCEPTDO
  134.     IF app THEN MUI_DisposeObject(app)
  135.     IF MUIMasterBase THEN CloseLibrary(MUIMasterBase)
  136.     IF exception THEN PrintF('\s\n',exception)
  137. ENDPROC
  138.